package com.springboot.framework.dao.mapper;

import com.springboot.framework.dao.entity.Product;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import tk.mybatis.mapper.common.Mapper;

public interface ProductMapper extends Mapper<Product> {


    @Update("update product set stock = stock - #{quantity} where id = #{productId} and stock >= #{quantity}")
    void decreaseStock(@Param("productId") Integer productId ,@Param("quantity") Integer quantity);

    @Update("update product set stock = stock + #{quantity} where id = #{productId}")
    void increaseStock(@Param("productId") Integer productId ,@Param("quantity") Integer quantity);
}